uniform vec2 chunk_pos;
uniform float global_illum;
uniform float wind;

void main(){
	vec4 pos = ge_VertexPosition;
	pos.w = 1.0;
	pos.xyz = pos.xyz / 128.0;
	pos.x = mod(pos.x, 128.0);
	pos.xy += chunk_pos;

	ge_Color = ge_VertexColor;
	ge_TexCoord0 = ge_VertexTexcoord / 32768.0;

	float local_light = (ge_VertexPosition.x / 4096.0) / 15.0;
	ge_Color.rgb *= clamp(global_illum + local_light, 0.0, 1.0);

	int n_anims = int(ge_VertexPosition.w / 256.0);
	float tex_h = mod(ge_VertexPosition.w, 256.0) / 256.0;
	if(n_anims > 1){
		ge_TexCoord0.y += tex_h * mod(floor(ge_Time * 20.0), float(n_anims));
	}

	ge_Position = ge_MatrixProjection * ge_MatrixModelView * pos;
}
